<template>
	<transition name="fade"><router-view></router-view></transition>
</template>

<script>
	export default {
		watch: {
			$route: {
				immediate: true,
				handler(to, from) {
					const {
						meta,
						params,
						query,
						name
					} = to;
					let title = '';
					if (meta.title) {
						title = meta.title;
					} else if (params && params.title) {
						title = params.title;
					} else if (query && query.title) {
						title = query.title;
					}
					document.title = title + ' - ' + window.SITE_CONFIG['title'];
				},
				deep: true
			}
		},
		mounted() {
			window.addEventListener(
				'hashchange',
				() => {
					let currentPath = window.location.hash.slice(1);
					if (this.$route.path !== currentPath) {
						this.$router.push(currentPath);
					}
				},
				false
			);
		}
	};
</script>